package com.weijia;

import javax.swing.*;
import java.awt.*;

public class PauseOverlay extends JPanel {
    private GameManager gameManager;
    public void setGameManager(GameManager gameManager) {
        this.gameManager = gameManager;
    }
    public PauseOverlay() {
        setOpaque(false);
        setLayout(new BorderLayout());
        JPanel centerPanel = new JPanel();
        centerPanel.setOpaque(false);
        JButton continueButton = new JButton("继续游戏");
        continueButton.setFont(new Font("SansSerif", Font.BOLD, 18));
        continueButton.setBackground(new Color(50, 180, 110));
        continueButton.setForeground(Color.WHITE);
        continueButton.setFocusPainted(false);
        continueButton.addActionListener(e -> {
            if (gameManager != null) gameManager.resumeGame();
        });
        centerPanel.add(continueButton);
        add(centerPanel, BorderLayout.CENTER);
    }
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (gameManager != null && gameManager.isGamePaused()) {
            g.setColor(new Color(0, 0, 0, 150));
            g.fillRect(0, 0, getWidth(), getHeight());
        }
    }
} 